package com.elysium.autoconfigure;

import com.elysium.properties.AppSettingProperties;
import com.elysium.template.AppWeChatTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({AppSettingProperties.class})
public class WeChatAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(
            name = {"weChatTemplate"}
    )
    public AppWeChatTemplate weChatTemplate(AppSettingProperties appSettingProperties) {
        AppWeChatTemplate appWeChatTemplate = new AppWeChatTemplate(appSettingProperties);
        return appWeChatTemplate;
    }

}
